<?php
// $conn = new PDO("mysql:host=localhost;dbname=php","root","root");
// if($conn){
//     $sql = "insert into user(username,password) values('oop','123456'),('oop','123456')";
//     $num = $conn->exec($sql);
    
// }

// echo '操作成功'.$num;


$db = new dbPDO();
$rows = $db->query("select * from user");
foreach ($rows as $row){
    echo $row->username;
}
//print_r($rows);


?>

<?php 
const aa = 999990;
if(true){
define("NAME", 'oop===',true);
}
var_dump(defined("aa1"));
echo name;
$dbp = new dbPDO();
echo $dbp::aaa;
echo dbPDO::aaa;
echo NAME;
 class dbPDO{
     const aaa = 231;
    
     public function __construct(){
         echo 'php的构造方法';
         $this->conn = new PDO("mysql:host=localhost;dbname=php","root","root");
         $this->conn->query("SET NAMES UTF8");
     }
     public  function query($sql){
        
        $rs = $this->conn->query($sql);
        
        while($row = $rs->fetch(5)){
           $rows[] = $row;
       }
       
       return $rows;
     }
     
     public static function show(stu $st){
        var_dump($st);
        $st->t();
     }
    
 } 
  class stu{
      public $name;
      public $age;
      function __construct($name,$age){
          $this->name = $name;
          $this->age = $age;
          echo __FUNCTION__;
      }
      
      public function te(){
          echo $this->name;
          echo $this->age;
          echo __FUNCTION__;
          echo __METHOD__;
      }
  
  }
   $j = json_encode(new stu('王五123123123',999));
  echo $j;
  $jj = json_decode($j,true);
  echo $jj['name']."===========";
    var_dump($jj);
    
     $arr = ['s','d','g'=>'ggf'];
    echo json_encode($arr);
     
     
   //  $stu = new stu("zhangsan", 2110);
 // $stu->te();
     
//      echo __FILE__;
//      echo __LINE__;
  //echo __DIR__.'==';
//      echo __CLASS__;
     
?>



<?php

echo 1123;

$conn = new PDO("mysql:host=localhost;dbname=test","root","root");
var_dump($conn);
if($conn){
  echo 1;
}else{
 echo 0;
}